package com.example.demo;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
/*
    创建消息生产者
 */
@Component
public class Sender {

    @Autowired
    private AmqpTemplate  amqpTemplate;

    public void send(){
        String context ="hello"+new Date();
        System.out.println("sender:"+context);
        this.amqpTemplate.convertAndSend("hello",context);
    }
}
